"""
    基于方法创建进程
"""
import multiprocessing
import random
import time

def worker(process_name):
    time.sleep(random.randint(3, 5))
    print(f"{process_name=}")

if __name__ == '__main__':
    for i in range(5,10):
        name = f'process_{i}'
        p = multiprocessing.Process(target=worker, args=(name,))
        p.start()
        p.join()

    print(f'CPU numbers: {multiprocessing.cpu_count()}')
    for p in multiprocessing.active_children():
        print(p.name)
    print('Process Ended')